<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>键盘事件</title>
    <script type="text/javascript" src="./js/vue.js"></script>
    <style>
        
    </style>
</head>
<div id="root">
    <h2>欢迎来到{{name}}学习</h2>
    <!--常用别名: enter delete esc space tab(配合keydown使用) up down left right-->
    <input type="text" placeholder="按下回车提示输入" @keyup.enter="showInfo" />
    <input type="text" placeholder="按下回车提示输入" @keyup="showInfo1" />
    <!--要转小写，多个单词使用-连接-->
    <input type="text" placeholder="按下CapsLock提示输入" @keyup.caps-lock="showInfo1" />
</div>
<script type="text/javascript">
    Vue.config.productionTip = false;

    new Vue({
        el: '#root',
        data: {
            name: '培立优'
        },
        methods: {
            showInfo(e){
                //console.log(e.keyCode);
                console.log(e.target.value);
            },
            showInfo1(e){
                console.log(e.keyCode, e.key);
            }
        }
    });
</script>

</html>